﻿﻿﻿﻿﻿package UIComponents// ActionScript file
{
	import Classes.GameUtils.GU_btnToMC;
	import Classes.GameUtils.HideSlideFastenerBtn;
	import Classes.GameUtils.MyTipSprite;
	import Classes.GameUtils.ToolTip_Sprite;
	import Classes.staticinfo.Language;
	import Classes.staticinfo.StaticInfo;
	
	import MyComponent.MyButton;
	
	import com.greensock.TweenLite;
	
	import fl.events.ComponentEvent;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.display.StageDisplayState;
	import flash.display.StageQuality;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class UIMain extends Sprite
	{
		private static const BUILDSET:String="buildSet";
		private static const MAINSET:String="mainSet";
		private static const CANNOTSET:String="cannotSet";
		private var _panelMainInitY:Number;
		private var _panelMain:PanelMain;
		private var _panelBuildInitY:Number;
		public var _panelBuild:PanelBuild;
		private var _panelState:String=MAINSET;
		public var _showTimerTf:TextField;
		public var _showTimerTips:TextField;
		private var _showTimerContainer:DisplayObjectContainer;
		private var _lianJiMC:MovieClip;
		private var _litf:TextField;
		private var _alertor:Sprite;
		
		private var _qqVipIconSp:DisplayObjectContainer;
		private var _newQqVip:DisplayObject;
		private var _dayQqVip:DisplayObject;
		private var _openQqVip:DisplayObject;
		
		//七日礼包跟动态礼包按钮
		private var _sevenGiftBtn:DisplayObject;
		private var _dongtaiGiftBtn:DisplayObject;
		private var _dongtaiTimer:TextField;
		private var _dongtaiLqBtn:SimpleButton;
		
		private var _jsIcon:DisplayObject;
		
		
		//消息系统
		public var Message:Sprite;
		public var MessageNew:MovieClip;
		public var txtMessageNew:TextField;
		public var txtMessageNewContainer:DisplayObjectContainer;
		
		//上下伸缩panelMain,panelBuild
		public var hideSlideFastenerBtn:HideSlideFastenerBtn;
		
		/**
		 * 声效全屏的上下伸缩面板 
		 */		
		public var doanmb:DisplayObjectContainer;
		
		
		/**
		 *true表示建筑模式，否则是表示普通模式 
		 */
		public var isBuildMode:Boolean=false;
		public function UIMain():void
		{
			this.init();
		}
		
		private function init():void
		{
			this._panelMain=(this.getChildByName("panel_main") as PanelMain);
			this._panelMainInitY=this.panelMain.y;
			this._panelBuild=(this.getChildByName("panel_build") as PanelBuild);
			this._panelBuildInitY=this.panelBuild.y;
			this.panelBuild.visible=false;
			this.panelBuild.y=760;//this.parent.stage.stageHeight;//760;
			this._showTimerContainer=this.getChildByName("timeBtn") as DisplayObjectContainer;
			this._showTimerTf=this.showTimerContainer.getChildByName("txt_countDown") as TextField;
			this._showTimerTips=this.showTimerContainer.getChildByName("txt_countDownDescription") as TextField
			
			//连击图片
			this._lianJiMC=this.getChildByName("lianji") as MovieClip;
			this.litf=this._lianJiMC.getChildByName("ljTxt") as TextField;
			
			//警报器
			this._alertor	= this.panelMain.getChildByName("alertor") as Sprite;
			
			//QQ黄钻元素
			this._qqVipIconSp=this.getChildByName("qqhzIcon") as DisplayObjectContainer;
			this._newQqVip=this._qqVipIconSp.getChildByName("newQQVip");
			this._dayQqVip=this._qqVipIconSp.getChildByName("dayQQLift");
			this._openQqVip=this._qqVipIconSp.getChildByName("getDayQQLift");
			(this._newQqVip as MovieClip).buttonMode=true;
			(this._openQqVip as MovieClip).buttonMode=true;
			(this._dayQqVip as MovieClip).buttonMode=true;
			
			//七日礼包跟动态礼包按钮
			this._sevenGiftBtn=this.getChildByName("sevenGiftBtn");
			this._dongtaiGiftBtn=this.getChildByName("dongtaiGiftBtn");
			this._dongtaiTimer=(this._dongtaiGiftBtn as DisplayObjectContainer).getChildByName("timerTf") as TextField;
			this._dongtaiLqBtn=(this._dongtaiGiftBtn as DisplayObjectContainer).getChildByName("lqbtn") as SimpleButton;
			(this._sevenGiftBtn as MovieClip).buttonMode=true;
			
			
			//消息系统
			this.Message		=	this.panelMain.getChildByName("Message") as Sprite;
			this.Message.buttonMode		=	true;
			
			this.MessageNew		=	this.panelMain.getChildByName("MessageNew") as MovieClip;
			this.MessageNew.buttonMode		=	true;
			this.txtMessageNewContainer		=	this.panelMain.getChildByName("txtNewMessageContainer") as DisplayObjectContainer;
			this.txtMessageNew		=	this.txtMessageNewContainer.getChildByName("txtNewMessageCount") as TextField;
			
			this.txtMessageNew.mouseEnabled=false;
			
			this._jsIcon=(this.getChildByName("playEleSp") as DisplayObjectContainer).getChildByName("ic1");
			
			this.button_package=this.panelMain.getChildByName("button_package") as MyButton;
			this.button_shop=this.panelMain.getChildByName("button_shop") as MyButton;
			this.button_building=this.panelMain.getChildByName("button_building") as MyButton;
			this.button_sure=this.panelBuild.getChildByName("button_sure");
			this.goHomeBtn=this.panelMain.getChildByName("goHomeBtn") as MyButton;
			
			//上下伸缩panelMain,panelBuild
			
			this.hideSlideFastenerBtn	=	new HideSlideFastenerBtn( this.getChildByName("UpDownMainPanel") as Sprite);
			
			
			
			this.addListener();
			
			//是否查看QQ黄钻按钮
			this.getChildByName("moneySp").visible=FlatInfo.isOpenSeeQb;
			this.getChildByName("txt_myOB").visible=FlatInfo.isOpenSeeQb;
			this.getChildByName("btn_myOB").visible=FlatInfo.isOpenSeeQb;
			this.getChildByName("qqmoneybg").visible=FlatInfo.isOpenSeeQb;
		}
		
		public var button_package:MyButton;
		public var button_shop:MyButton;
		public var button_building:MyButton;
		public var button_sure:DisplayObject;
		public var goHomeBtn:MyButton;
		
		private function addListener():void
		{
			(this.panelMain.getChildByName("button_package") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,showPackageHandler);
			(this.panelMain.getChildByName("button_shop") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,showShopHandler);
			(this.panelMain.getChildByName("button_building") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,showBuildingHandler);
			(this.panelMain.getChildByName("goHomeBtn") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,goHomeFun);
			this.panelMain.addEventListener("addarrowtobuilid",addArrowBuild);
			this.panelMain.addEventListener("addarrowtock",addArrowCK);
			this.panelMain.addEventListener("addarrowtozs",addArrowZS);
			this.panelBuild.getChildByName("button_sure").addEventListener(MouseEvent.CLICK,sureHandler);
			this.panelBuild.getChildByName("button_move").addEventListener(MouseEvent.CLICK,moveHandler);
			this.panelBuild.getChildByName("button_clean").addEventListener(MouseEvent.CLICK,cleanHandler);
			this.panelBuild.getChildByName("button_return").addEventListener(MouseEvent.CLICK,returnHandler);
			this.panelMain.qhWqPanel.addEventListener("changeUserWeapon",chageWeapon);
			
			//新手指导
			this.panelMain.qhWqPanel.addEventListener("addarrow",addarrow);
			this.panelMain.qhWqPanel.addEventListener("notnewguidesd",notnewguidesd);
			this.panelMain.getFriendFrame(1).addEventListener("friendrollover",friendrollover);
			this.panelMain.getFriendFrame(1).addEventListener("friendrollout",friendrollout);
			
			(this.getChildByName("btn_myJB") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,showExChangeHandler);
			//(this.getChildByName("btn_myJB") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,btnMyOBHandler);
			
			//建筑工具提示
			ToolTip_Sprite.getInstance().setTip(this.panelBuild.getChildByName("button_move") as DisplayObject,new MyTipSprite(Language.buildTipMove),ToolTip_Sprite.DIRECTION_LEFT);
			ToolTip_Sprite.getInstance().setTip(this.panelBuild.getChildByName("button_return") as DisplayObject,new MyTipSprite(Language.buildTipRecall),ToolTip_Sprite.DIRECTION_LEFT);
			ToolTip_Sprite.getInstance().setTip(this.panelBuild.getChildByName("button_clean") as DisplayObject,new MyTipSprite(Language.buildTipDelete),ToolTip_Sprite.DIRECTION_LEFT);
			ToolTip_Sprite.getInstance().setTip(this.panelBuild.getChildByName("button_sure") as DisplayObject,new MyTipSprite(Language.buildTipSure),ToolTip_Sprite.DIRECTION_LEFT);
			
			this.panelBuild.addEventListener(MouseEvent.ROLL_OVER,fbOverhandler);//鼠标移动到建筑面板
			this.panelBuild.addEventListener(MouseEvent.ROLL_OUT,fbOuthandler);//鼠标移开到建筑面板
			this.panelBuild.addEventListener(MouseEvent.CLICK,fbDownhandler );//鼠标点击到建筑面板
			//this.panelBuild.addEventListener("isClickItem",fbNoclickhandler);//鼠标没有点击到建筑面板中的项
			this.panelBuild.getChildByName("button_sure").addEventListener(MouseEvent.MOUSE_DOWN,fbsDownHandler);//鼠标按在确认按扭
			(this.panelMain.getChildByName("yqFriendBtn") as MyButton).addEventListener(ComponentEvent.BUTTON_DOWN,yqhyFun);
			
			//给黄钻按钮加事件
			this._newQqVip.addEventListener(MouseEvent.CLICK,openNewqqVip);
			this._dayQqVip.addEventListener(MouseEvent.CLICK,openDayqqVip);
			this._openQqVip.addEventListener(MouseEvent.CLICK,openDayqqVipLater);
			
			//声效全屏这一块
			var sxIc:DisplayObjectContainer=this.getChildByName("bar_system") as DisplayObjectContainer;
			doanmb=sxIc.getChildByName("downmusicmb") as DisplayObjectContainer; 
			sxIc.getChildByName("controlMusicBtn").addEventListener(ComponentEvent.BUTTON_DOWN,controlMusicFun);
			doanmb.getChildByName("bgMusicBtn").addEventListener(ComponentEvent.BUTTON_DOWN,controlBgMusicFun);
			doanmb.getChildByName("commMusicBtn").addEventListener(ComponentEvent.BUTTON_DOWN,controlCommMusicFun);
			doanmb.getChildByName("fullScreenBtn").addEventListener(MouseEvent.CLICK,controlFullScreenFun);
			doanmb.getChildByName("fullScreenBtn").addEventListener(MouseEvent.MOUSE_OVER,updateIsFull);
			doanmb.getChildByName("tipsBtn").addEventListener(ComponentEvent.BUTTON_DOWN,controlTipsFun);
			
			//系统热感
			ToolTip_Sprite.getInstance().setTip(sxIc.getChildByName("controlMusicBtn") as DisplayObject,new MyTipSprite(Language.offShow),ToolTip_Sprite.DIRECTION_LEFT,true);
			ToolTip_Sprite.getInstance().setTip(doanmb.getChildByName("bgMusicBtn") as DisplayObject,new MyTipSprite(Language.offBgMusic),ToolTip_Sprite.DIRECTION_LEFT,true);
			ToolTip_Sprite.getInstance().setTip(doanmb.getChildByName("commMusicBtn") as DisplayObject,new MyTipSprite(Language.offCommMusic),ToolTip_Sprite.DIRECTION_LEFT,true);
			ToolTip_Sprite.getInstance().setTip(doanmb.getChildByName("fullScreenBtn") as DisplayObject,new MyTipSprite(Language.onFullScreen),ToolTip_Sprite.DIRECTION_LEFT,true);
			ToolTip_Sprite.getInstance().setTip(doanmb.getChildByName("tipsBtn") as DisplayObject,new MyTipSprite(Language.onTipDown),ToolTip_Sprite.DIRECTION_LEFT,true);
			
			//七日礼包跟动态礼包按钮
			this._sevenGiftBtn.addEventListener(MouseEvent.CLICK,sevenFun);
			this._dongtaiLqBtn.addEventListener(MouseEvent.CLICK,dongtaiFun);
			
			//消息系统
			this.Message.addEventListener(MouseEvent.CLICK,messageClickHD);
			this.MessageNew.addEventListener(MouseEvent.CLICK,messageClickHD);
			
			//金币，经验，行动力热感
			(this.getChildByName("txt_exp") as TextField).mouseEnabled=false;
			(this.getChildByName("txt_friendActPoint") as TextField).mouseEnabled=false;
			(this.getChildByName("txt_actPoint") as TextField).mouseEnabled=false;
			(this.getChildByName("txt_myJB") as TextField).mouseEnabled=false;
			(this.getChildByName("txt_myOB") as TextField).mouseEnabled=false;
			(this.getChildByName("bar_exp") as Sprite).mouseChildren	= (this.getChildByName("bar_exp") as Sprite).mouseEnabled	=false;	
			
			(this.getChildByName("bar_friendActPoint") as Sprite).mouseChildren	= (this.getChildByName("bar_friendActPoint") as Sprite).mouseEnabled	=false;
			(this.getChildByName("bar_actPoint") as Sprite).mouseChildren	= (this.getChildByName("bar_actPoint") as Sprite).mouseEnabled	=false;
			
			ToolTip_Sprite.getInstance().setTip(this.getChildByName("expBar")   as DisplayObject,new MyTipSprite(Language.expHint),ToolTip_Sprite.DIRECTION_DOWN,true);
			ToolTip_Sprite.getInstance().setTip(this.getChildByName("powerBar") as DisplayObject,new MyTipSprite(Language.powerHint),ToolTip_Sprite.DIRECTION_DOWN,true);
			ToolTip_Sprite.getInstance().setTip(this.getChildByName("btn_myJB") as DisplayObject,new MyTipSprite(Language.moneyHint),ToolTip_Sprite.DIRECTION_DOWN,true);
			ToolTip_Sprite.getInstance().setTip(this.getChildByName("btn_myOB") as DisplayObject,new MyTipSprite(Language.omoneyHint),ToolTip_Sprite.DIRECTION_DOWN,true);
			
			//			ToolTip_Sprite.getInstance().setTip(this.getChildByName("txt_exp")   as DisplayObject,new MyTipSprite(Language.expHint),ToolTip_Sprite.DIRECTION_RIGHT,true);
			//			ToolTip_Sprite.getInstance().setTip(this.getChildByName("txt_friendActPoint") as DisplayObject,new MyTipSprite(Language.powerHint),ToolTip_Sprite.DIRECTION_LEFT,true);
			//			ToolTip_Sprite.getInstance().setTip(this.getChildByName("txt_myJB") as DisplayObject,new MyTipSprite(Language.moneyHint),ToolTip_Sprite.DIRECTION_LEFT,true);
			//			ToolTip_Sprite.getInstance().setTip(this.getChildByName("txt_myOB") as DisplayObject,new MyTipSprite(Language.omoneyHint),ToolTip_Sprite.DIRECTION_LEFT,true);
			
			//上下伸缩panelMain,panelBuild
			//点了齿轮
			this.hideSlideFastenerBtn.targetUI.addEventListener("clickCL", clickCLHandler);
		}
		
		public function addArrowBuild(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.ADDARROWTOBUILID,true));
		}
		public function addArrowCK(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.ADDARROWTOCK,true));
		}
		public function addArrowZS(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.ADDARROWTOZS,true));
		}
		
		private function messageClickHD(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent("messageClick",true));
		}
		
		/**
		 * 邀请好友 
		 * @param e
		 */		
		private function yqhyFun(e:ComponentEvent):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.YQHY,true));
		}
		
		/**
		 * 七日礼包 
		 * @param e
		 */		
		private function sevenFun(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent("sevenFun",true));
		}
		
		/**
		 * 动态礼包 
		 * @param e
		 */		
		private function dongtaiFun(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent("dongtaiFun",true));
		}
		
		/**
		 * 控制七日礼包的显示 
		 * @param isvisable
		 */		
		public function controlSevenBtn(isvisable:Boolean):void
		{
			this._sevenGiftBtn.visible=isvisable;
		}
		
		/**
		 * 控制七日礼包是否摆动 
		 * @param isvisable
		 */		
		public function controlPlaySevenBtn():void
		{
			(this._sevenGiftBtn as MovieClip).stop();
			
		}
		
		/**
		 * 控制动态礼包是否摆动 
		 * @param isvisable
		 */		
		public function playOrStopDongTaiBtn(play:String):void
		{
			if(play=="play")
			{
				(this._dongtaiGiftBtn as MovieClip).play();
			}else{
				(this._dongtaiGiftBtn as MovieClip).stop();
			}
		}
		
		/**
		 * 控制动态礼包的显示 
		 * @param isvisable
		 */		
		public function controlDongtaiBtn(isvisable:Boolean):void
		{
			this._dongtaiGiftBtn.visible=isvisable;
		}
		
		/**
		 * 控制动态时间倒计时 
		 * @param value
		 */		
		public function setDongtaiTimer(value:String):void
		{
			this._dongtaiTimer.text=value;
		}
		
		/**
		 * 控制动态里面领取按钮  是否可以领取
		 * @param isVisabel
		 */		
		public function controlDongTaiLqBtn(isVisabel:Boolean,fliter:Array):void
		{
			this._dongtaiLqBtn.mouseEnabled=isVisabel;
			this._dongtaiLqBtn.filters=fliter;
			if(isVisabel)
			{
				playOrStopDongTaiBtn("play");
			}else{
				playOrStopDongTaiBtn("stop");
			}
		}
		
		/**
		 * 得到购买建筑的第一块面板 
		 * @return 
		 * 
		 */		
		public function get buildBuyItem1():DisplayObject
		{
			return this.panelBuild.getFrameBuildingItemByIndex(0);
		}
		/**
		 * 得到购买建筑的第5块面板 
		 * @return 
		 * 
		 */		
		public function get buildBuyItem5():DisplayObject
		{
			return this.panelBuild.getFrameBuildingItemByIndex(4);
		}
		
		public var duflag:String="down";
		//声效全屏这一块  功能
		/**
		 * 控制声效上下拉伸 
		 * @param e
		 */		
		private function controlMusicFun(e:ComponentEvent):void
		{
			var target:DisplayObject = e.currentTarget as DisplayObject;
			var container:DisplayObjectContainer = target.stage as DisplayObjectContainer;
			if(container == null) return;
			var tip:DisplayObject = container.getChildByName("tip");
			if(tip)	container.removeChild(tip);
			
			if(duflag=="down")
			{
				duflag="up"
				TweenLite.to(this.doanmb,0.5,{y:-110});		//y:-77.5 old
				ToolTip_Sprite.getInstance().setTipTxt(Language.onShow,target,true);
				
			}else{
				duflag="down"
				TweenLite.to(this.doanmb,0.5,{y:19.85});
				ToolTip_Sprite.getInstance().setTipTxt(Language.offShow,target,true);
			}
		}
		
		
		public function setPlayEle1(dis:DisplayObject=null,tips:String=""):void
		{
			((this.getChildByName("playEleSp") as DisplayObjectContainer).getChildByName("ic0") as IconContainer).addPic(dis,tips);
		}
		
		public function setPlayerEle2(dis:DisplayObject=null,tips:String=""):void
		{
			
			((this.getChildByName("playEleSp") as DisplayObjectContainer).getChildByName("ic1") as IconContainer).addPic(dis,tips);
		}
		
		public function setPlayEle3(dis:DisplayObject=null,tips:String=""):void
		{
			((this.getChildByName("playEleSp") as DisplayObjectContainer).getChildByName("ic2") as IconContainer).addPic(dis,tips);
		}
		
		public function get PlayerEle2Tips():DisplayObject
		{
			return this._jsIcon;
		}
		
		public function keyFun(e:KeyboardEvent):void
		{
			//			trace("keyCode"+e.keyCode);
			this.panelMain.qhWqPanel.keyFun(e);
		}
		
		public function get upOrDownBtn():DisplayObject
		{
			return this.panelMain.qhWqPanel.qhBtn;
		}
		
		public function get selectWeaponInnerPanel2():DisplayObject
		{
			return this.panelMain.qhWqPanel.getWqFrame(1);
		}
		
		/**
		 * 控制背景音乐 
		 * @param e
		 */	
		private function controlBgMusicFun(e:ComponentEvent):void
		{
			this.dispatchEvent(new PanelEvent("BgMusic",true));
		}
		/**
		 * 控制声效
		 * @param e
		 */	
		private function controlCommMusicFun(e:ComponentEvent):void
		{
			this.dispatchEvent(new PanelEvent("CommMusic",true));
		}
		
		//是否全屏
		private var _isFullScreen:Boolean	=	false;
		/**
		 * 控制全屏
		 * @param e
		 */	
		private function controlFullScreenFun(e:Event):void
		{
			this.dispatchEvent(new Event("fullScreenClick",true));
		}
		public function get isFullScreen():Boolean
		{
			return _isFullScreen;
		}
		public function set isFullScreen(value:Boolean):void
		{
			this._isFullScreen	=	value;
			if(_isFullScreen){
				ToolTip_Sprite.getInstance().setTipTxt(Language.offFullScreen,doanmb.getChildByName("fullScreenBtn"),true);
//				doanmb.getChildByName("fullScreenBtn").filters	=	StaticInfo.DARKER_DISABLE_FILTER;
			}
			else{
				ToolTip_Sprite.getInstance().setTipTxt(Language.onFullScreen,doanmb.getChildByName("fullScreenBtn"),true);
//				doanmb.getChildByName("fullScreenBtn").filters	=	null;
			}
		}
		public function updateIsFull(e:Event):void
		{
			this._isFullScreen	=	(this.parent.stage.displayState==StageDisplayState.FULL_SCREEN)?true:false;
			
			//关闭热感
			var target:DisplayObject = e.currentTarget as DisplayObject;
			var container:DisplayObjectContainer = target.stage as DisplayObjectContainer;
			if(container == null) return;
			var tip:DisplayObject = container.getChildByName("tip");
			if(tip)	container.removeChild(tip);
			
			if(_isFullScreen){
				ToolTip_Sprite.getInstance().setTipTxt(Language.offFullScreen,doanmb.getChildByName("fullScreenBtn"),true);
//				doanmb.getChildByName("fullScreenBtn").filters	=	StaticInfo.DARKER_DISABLE_FILTER;
			}
			else{
				ToolTip_Sprite.getInstance().setTipTxt(Language.onFullScreen,doanmb.getChildByName("fullScreenBtn"),true);
//				doanmb.getChildByName("fullScreenBtn").filters	=	null;
			}
			
			e.currentTarget.dispatchEvent(new MouseEvent(MouseEvent.ROLL_OVER));
		}
		//-----------以上都 是全屏有关
		
		
		
		private var isTipGrade:uint=3;//1底，2中，3高
		/**
		 * 控制显示tip
		 * @param e
		 */	
		private function controlTipsFun(e:ComponentEvent):void
		{
			
			//关闭热感
			var target:DisplayObject = e.currentTarget as DisplayObject;
			var container:DisplayObjectContainer = target.stage as DisplayObjectContainer;
			if(container == null) return;
			var tip:DisplayObject = container.getChildByName("tip");
			if(tip)	container.removeChild(tip);
			isTipGrade++;
			if(isTipGrade>3)isTipGrade=1;
			
			switch(isTipGrade)
			{
				case 1:
					ToolTip_Sprite.getInstance().setTipTxt(Language.onTipDown,target,true);
					stage.quality	=	StageQuality.LOW;
					break;
				case 2:
					ToolTip_Sprite.getInstance().setTipTxt(Language.onTipUp,target,true);
					stage.quality	=	StageQuality.MEDIUM;
					break;
				case 3:
					ToolTip_Sprite.getInstance().setTipTxt(Language.onTipMiddle,target,true);
					stage.quality	=	StageQuality.HIGH;
					break;
			}
		}
		
		private function fbOverhandler(e:Event){this.dispatchEvent(new PanelEvent("PB_mouseOVER",true));} //鼠标移动到建筑面板处理
		private function fbOuthandler(e:Event){this.dispatchEvent(new PanelEvent("PB_mouseOUT",true));} 	//鼠标移开到建筑面板处理
		private function fbDownhandler(e:Event){this.dispatchEvent(new PanelEvent("PB_mouseDOWN",true));} //鼠标点击到建筑面板处理
		private function fbsDownHandler(e:Event){this.dispatchEvent(new PanelEvent("PB_sureDOWN",true));} //鼠标点击到建筑面板处理
		
		public var currentWeaponId:String;
		private function chageWeapon(e:Event):void
		{
			this.currentWeaponId=this.panelMain.qhWqPanel.currentWeaponId;
			this.dispatchEvent(new PanelEvent(PanelEvent.CHANGEUSERWEAPON,true));
		}
		
		//***************newguide* start******
		private function addarrow(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.ADDARROW,true));
		}
		
		private function notnewguidesd(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.NOTNEWGUIDESD,true));
		}
		
		public function get friendFrame2():DisplayObject
		{
			return this.panelMain.getFriendFrame(1);
		}
		
		public function get friendVisableBtn():DisplayObject
		{
			return this.panelMain.getFriendFrame(1)["visibleBtn"];
		}
		
		public function get friendFireBtn():DisplayObject
		{
			return this.panelMain.getFriendFrame(1)["hireBtn"];
		}
		
		/**
		 *设置当前拜访的好友id 
		 * @param id
		 * 
		 */
		public function set visibleFriendId(id:int):void
		{
			this.panelMain.setVisibleId(id);
		}
		
		
		
		public function  friendrollover(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.FRIENDROLLOVER,true));
		}
		
		public function  friendrollout(e:Event):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.FRIENDROLLOUT,true));
		}
		
		
		//***************newguide end*******
		
		public function setQhWqData(obj:Object):void
		{
			this.panelMain.qhWqPanel.setSelectWeaponObjData(obj);
		}
		
		public function setFriendData(arr:Array):void
		{
			this.panelMain.setFriendArr(arr);
		}
		
		public function updataExchangeBuildItemNum(value:String):void
		{
			this.panelBuild.exchangeItemNum.text=value;
		}
		
		private function removeListener():void
		{
			//			(this.panelMain.getChildByName("button_img") as MyButton).removeEventListener(ComponentEvent.BUTTON_DOWN,showImgHandler);
			(this.panelMain.getChildByName("button_package") as MyButton).removeEventListener(ComponentEvent.BUTTON_DOWN,showPackageHandler);
			(this.panelMain.getChildByName("button_shop") as MyButton).removeEventListener(ComponentEvent.BUTTON_DOWN,showShopHandler);
			(this.panelMain.getChildByName("button_building") as MyButton).removeEventListener(ComponentEvent.BUTTON_DOWN,showBuildingHandler);
			(this.panelMain.getChildByName("goHomeBtn") as MyButton).removeEventListener(ComponentEvent.BUTTON_DOWN,goHomeFun);
			this.panelBuild.getChildByName("button_sure").removeEventListener(MouseEvent.CLICK,sureHandler);
			this.panelBuild.getChildByName("button_move").removeEventListener(MouseEvent.CLICK,moveHandler);
			this.panelBuild.getChildByName("button_clean").removeEventListener(MouseEvent.CLICK,cleanHandler);
			this.panelBuild.getChildByName("button_return").removeEventListener(MouseEvent.CLICK,returnHandler);
			
			this.panelBuild.removeEventListener(MouseEvent.ROLL_OVER,fbOverhandler);//鼠标移动到建筑面板
			this.panelBuild.removeEventListener(MouseEvent.ROLL_OUT,fbOuthandler);//鼠标移开到建筑面板
			this.panelBuild.removeEventListener(MouseEvent.CLICK,fbDownhandler );//鼠标点击到建筑面板
			
			this._newQqVip.removeEventListener(MouseEvent.CLICK,openNewqqVip);
			this._dayQqVip.removeEventListener(MouseEvent.CLICK,openDayqqVip);
			this._openQqVip.removeEventListener(MouseEvent.CLICK,openDayqqVipLater);
		}
		
		//黄钻
		private function openNewqqVip(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent("openNewqqVip",true));
		}
		
		//黄钻
		private function openDayqqVip(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent("openDayqqVip",true));
		}
		//黄钻
		private function openDayqqVipLater(e:MouseEvent):void
		{
			this.dispatchEvent(new PanelEvent("openDayqqVipLater",true));
		}
		
		/**
		 * 控制VIP的显示 
		 * @param newVip
		 * @param dayVip
		 * @param openVip
		 */		
		public function controlBtnVisable(newVip:Boolean,dayVip:Boolean,openVip:Boolean):void
		{
			this._newQqVip.visible=newVip;
			this._dayQqVip.visible=dayVip;
			this._openQqVip.visible=openVip;
		}
		
		public function controlMoenyIcon(qb:Boolean=true):void
		{
			var ms:DisplayObjectContainer=this.getChildByName("moneySp") as DisplayObjectContainer;
			ms.getChildByName("qdian").visible=qb;
			ms.getChildByName("obIcon").visible=!qb;
			ms.visible=FlatInfo.isOpenSeeQb;
			this.getChildByName("btn_myOB").visible=FlatInfo.isOpenSeeQb;
		}
		
		
		/**
		 *点击我的金币“加号” 
		 * @param e
		 * 
		 */
		public function showExChangeHandler(e:Event):void
		{
			if(FlatInfo.isOpenExchangMoney)
			{
				this.dispatchEvent(new PanelEvent("openExChange",true));
			}
		}
		public function setBuildBtnVisabel(arg:Boolean):void
		{
			this.panelMain.getChildByName("button_building").visible=arg;
			this.panelMain.getChildByName("goHomeBtn").visible=!arg;
			ToolTip_Sprite.getInstance().removeTip(this.getChildByName("powerBar") );
			if(arg)
			{
				ToolTip_Sprite.getInstance().setTip(this.getChildByName("powerBar") as DisplayObject,new MyTipSprite(Language.powerHint),ToolTip_Sprite.DIRECTION_DOWN,true);
			}else{
				ToolTip_Sprite.getInstance().setTip(this.getChildByName("powerBar") as DisplayObject,new MyTipSprite(Language.powerFriendHint),ToolTip_Sprite.DIRECTION_DOWN,true);
			}
		}
		
		private function sureHandler(e:MouseEvent):void
		{
			if(this.panelState!=BUILDSET)return;
//			this.showMainPanel();
			this.dispatchEvent(new PanelEvent(PanelEvent.FINISHBUILD,true));
		}
		
		private function moveHandler(e:MouseEvent):void
		{
			if(this.panelState!=BUILDSET)return;
			this.dispatchEvent(new PanelEvent(PanelEvent.CHANGETOMOVEMODE,true));
		}
		
		private function cleanHandler(e:MouseEvent):void
		{
			if(this.panelState!=BUILDSET)return;
			this.dispatchEvent(new PanelEvent(PanelEvent.CHANGETOCLEANMODE,true));
		}
		
		private function returnHandler(e:MouseEvent):void
		{
			if(this.panelState!=BUILDSET)return;
			this.dispatchEvent(new PanelEvent(PanelEvent.RECOVERBUILD,true));
		}
		
		private function showImgHandler(e:ComponentEvent):void
		{
			if(this.panelState!=MAINSET)return;
			this.dispatchEvent(new PanelEvent(PanelEvent.OPENIMGPANEL,true));
		}
		
		private function showPackageHandler(e:ComponentEvent):void
		{
			if(this.panelState!=MAINSET)return;
			this.dispatchEvent(new PanelEvent(PanelEvent.OPENPACKAGEPANEL,true));
		}
		
		private function goHomeFun(e:ComponentEvent):void
		{
			this.dispatchEvent(new PanelEvent(PanelEvent.GOHOMEEVENT,true));
		}
		
		private function showShopHandler(e:ComponentEvent):void
		{
			if(this.panelState!=MAINSET)return;
			this.dispatchEvent(new PanelEvent(PanelEvent.OPENSHOPPANEL,true));
		}
		
		private function showBuildingHandler(e:ComponentEvent):void
		{
			if(this.panelState!=MAINSET)return;
			//			this.showBuildPanel();
			this.dispatchEvent(new PanelEvent(PanelEvent.OPENBUILDINGPANEL,true));
		}
		
		public var BPdefaultY:Number=760 + 181;
		public var MPdefaultY:Number=760 + 200;
		public function showBuildPanel():void
		{
			this.panelState=CANNOTSET;
			this.panelBuild.visible=true;
			TweenLite.to(this.panelMain,0.5,{y:BPdefaultY,visible:false,onComplete:buildPanelEnabled});//760
			TweenLite.to(this.panelBuild,0.5,{y:this.panelBuildInitY});
			
			this.isBuildMode=true;
		}
		
		public function showMainPanel():void
		{
			this.panelState=CANNOTSET;
			this.panelMain.visible=true;
			TweenLite.to(this.panelMain,0.5,{y:this.panelMainInitY,onComplete:mainPanelEnabled});
			TweenLite.to(this.panelBuild,0.5,{y:MPdefaultY,visible:false});		//760
			
			this.isBuildMode=false;
		}
		
		public function controlerActPanel(inMyHome:Boolean=true):void
		{
			this.getChildByName("txt_actPoint").visible=inMyHome;
			this.getChildByName("bar_actPoint").visible=inMyHome;
			this.getChildByName("actPointPic").visible=inMyHome;
			this.getChildByName("txt_friendActPoint").visible=!inMyHome; 
			this.getChildByName("bar_friendActPoint").visible=!inMyHome; 
			this.getChildByName("actPointPic_friend").visible=!inMyHome;
		}
		
		private function buildPanelEnabled():void
		{
			this.panelState=BUILDSET;
		}
		
		private function mainPanelEnabled():void
		{
			this.panelState=MAINSET;
		}
		
		public function showMyJB(value:int):void
		{
			if(value<0)value=0;
			(this.getChildByName("txt_myJB") as TextField).text=String(value);
		}
		
		public function showMyOB(value:int):void
		{
			if(value<0)value=0;
			(this.getChildByName("txt_myOB") as TextField).text=String(value);
		}
		
		public function showPlayerLv(value:Number):void
		{
			(this.getChildByName("txt_playerLv") as TextField).text=String(value);
		}
		
		
		public function showTimes(value:String):void
		{
			this._showTimerTf.text=value;
		}
		
		public function showTownName(value:String):void
		{
			(this.panelMain.getChildByName("txt_townName") as TextField).text=String(value);
		}
		
		public function showExp(nowExp:Number,maxExp:Number):void
		{
			if(nowExp<0)nowExp=0;
			this.setExpPercent(int(nowExp/maxExp*100));
			(this.getChildByName("txt_exp") as TextField).text=nowExp+"/"+maxExp;
		}
		
		public function showActPoint(nowActPoint:int,maxActPoint:int):void
		{
			if(nowActPoint<0)nowActPoint=0;
			this.setActPointPercent(int(nowActPoint/maxActPoint*100));
			(this.getChildByName("txt_actPoint") as TextField).text=nowActPoint+"/"+maxActPoint;
		}
		
		public function showFriendAct(nowActPoint:int,maxActPoint:int):void
		{
			if(nowActPoint<0)nowActPoint=0;
			this.setFriendActPointPercent(int(nowActPoint/maxActPoint*100));
			(this.getChildByName("txt_friendActPoint") as TextField).text=nowActPoint+"/"+maxActPoint;
		}
		
		public function setExpPercent(value:int):void
		{
			(this.getChildByName("bar_exp") as MovieClip).gotoAndStop(value);
		}
		
		public function setActPointPercent(value:int):void
		{
			(this.getChildByName("bar_actPoint") as MovieClip).gotoAndStop(value);
		}
		
		public function setFriendActPointPercent(value:int):void
		{
			(this.getChildByName("bar_friendActPoint") as MovieClip).gotoAndStop(value);
		}
		
		public function setMissionsAry(value:Array):void
		{
			(this.getChildByName("bar_missions") as BarMissions).setMissionsAry(value);
		}
		
		public function release():void
		{
			
		}
		
		public function setShopDecorationsAry(shopDecorationsAry:Array):void
		{
			this.panelBuild.setShopDecorationsAry(shopDecorationsAry);
		}
		
		public function setShopBuildingsAry(shopBuildingsAry:Array):void
		{
			this.panelBuild.setShopBuildingsAry(shopBuildingsAry);
		}
		
		public function setStorageBuildingsAry(storageBuildingsAry:Array):void
		{
			this.panelBuild.setStorageBuildingsAry(storageBuildingsAry);
		}
		
		public function get panelMain():PanelMain
		{
			return _panelMain;
		}
		
		public function get panelState():String
		{
			return _panelState;
		}
		
		public function set panelState(value:String):void
		{
			_panelState = value;
		}
		
		public function get panelMainInitY():Number
		{
			return _panelMainInitY;
		}
		
		public function set panelBuildInitY(value:Number):void
		{
			_panelBuildInitY	=	value;
		}
		
		public function set panelMainInitY(value:Number):void
		{
			_panelMainInitY		=	value;
		}
		
		public function get panelBuildInitY():Number
		{
			return _panelBuildInitY;
		}
		
		public function get panelBuild():PanelBuild
		{
			return _panelBuild;
		}
		
		public function get showTimerContainer():DisplayObjectContainer
		{
			return _showTimerContainer;
		}
		
		public function get lianJiMC():MovieClip
		{
			return _lianJiMC;
		}
		
		public function get litf():TextField
		{
			return _litf;
		}
		
		public function set litf(value:TextField):void
		{
			_litf = value;
		}
		
		public function get alertor():Sprite
		{
			return this._alertor;
			
		}
		
		//======================================================================
		private var _isHideMainPanel:Boolean=false;
		private var _oldMainY:Number;
		private var _oldBuildY:Number;
		private var _isMoveMainPanel:Boolean=false;
		private var _isMoveBuildPanel:Boolean=false;
		/**
		 *设置隐藏vpMain 
		 * @param value
		 * 
		 */
		public function set isHideMainPanel(value:Boolean):void
		{
			//			trace("key",this._isMoveMainPanel,this._isMoveBuildPanel,value,this.interfaceUI["panelMain"].y,this.interfaceUI["panelBuild"].y);
			if(_isHideMainPanel==value)return;
			//			if(this._isMoveBuildPanel || this._isMoveMainPanel)return;
			
			if(value){
				this._isMoveBuildPanel	= true;
				this._isMoveMainPanel	= true;
				TweenLite.to(panelMain,0.5,{y:panelMain.y+panelMain.height,onComplete:setMovePanel("main",false)});
				TweenLite.to(panelBuild,0.5,{y:panelBuild.y+panelBuild.height,onComplete:setMovePanel("build",false)});
			}
			else{
				this._isMoveBuildPanel	= true;
				this._isMoveMainPanel	= true;
//				if(GV_Map.instance.buildMode==GV_Map.CANNOTBUILDMODE)
					TweenLite.to(panelMain,0.5,{y:panelMainInitY,onComplete:setMovePanel("main",false)});
//				else
					TweenLite.to(panelBuild,0.5,{y:panelBuildInitY,onComplete:setMovePanel("build",false)});
			}
			
			_isHideMainPanel		=	value;
		}
		public function get isHideMainPanel():Boolean
		{
			return _isHideMainPanel;
		}
		
		public function setMovePanel(panel:String,value:Boolean):void
		{
			
			if(panel=="main")this._isMoveMainPanel=value;
			if(panel=="build")this._isMoveBuildPanel=value;
		}
		
		/**
		 *单击了齿轮 
		 * @param e
		 * 
		 */
		public function clickCLHandler(e:Event):void
		{
			if( this.hideSlideFastenerBtn.clickCL	== "small")	//下拉
			{
//				this.isHideMainPanel(true);
				this.dispatchEvent( new Event("clickCLSmall", true));
			}
			else													//上拉
			{
				this.dispatchEvent( new Event("clickCLBig", true));
//				this.isHideMainPanel(false);
			}
		}
	}
}